package com.wss.service.fegin.fallbackFactory;

import com.wss.common.model.Result;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import com.wss.service.fegin.EmailService;


@Component
@Slf4j
public class EmailServiceFallbackFactory implements FallbackFactory<EmailService> {

    @Override
    public EmailService create(Throwable throwable) {
        return new EmailService() {
            @Override
            public Result sendEmail(String email, String code) {
                log.error(throwable.getMessage(),throwable);
                return Result.fail(throwable.getMessage());
            }
        };
    }
}
